package com.kuang.controller;

import com.kuang.common.anno.IgnoreToken;
import com.kuang.common.limit.annotation.AccessIpLimiter;
import com.kuang.entity.Product;
import com.kuang.service.product.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ProductController extends BaseController {


    @Autowired
    private ProductService productService;

    @GetMapping("/product/list")
    @AccessIpLimiter(limit = 5, timeout = 1)
    public List<Product> productList() {
        return productService.list();
    }


    @GetMapping("/product/get/{id}")
    @AccessIpLimiter(limit = 5, timeout = 1)
    @IgnoreToken
    public Product getProduct(@PathVariable("id") Long id) {
        return productService.getById(id);
    }
}
